﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Omu.AwesomeMvc;
using MvcApplication4.Models;


namespace MvcApplication4.Controllers
{
    public class LoteAjaxDropdownController : Controller
    {
        private readonly BD_Vacinas2Context _db = new BD_Vacinas2Context();

        public ActionResult GetItems(int? v, int? parent)
        {
            return Json(_db.LOTEs.Where(o => o.tb_Vacina.Nome_Vacina != null && o.tb_Vacina.ID_Vacina == parent && o.Validade >= DateTime.Now && o.Num_Doses > 1).ToList()
                            .Select(o => new SelectableItem(o.ID_Lote, o.ID_Lote)));// key, text, selected
        }

    }
}
